module(...,package.seeall)
vipUuids={
  "a0dbba24-3158-4bbd-915d-6508d0e9bd27",
  "e1398432-ae36-42d5-9d2e-9f287a42702f",
  "ab52355a-f0eb-4908-aef1-61a31e95905b",
  "24d9a087-a78c-4e42-9979-57c36d904989",
  "1e947f19-4f94-4fef-b4f1-7f08613c188a",
}
fuckUuids={
  "f57a3f4c-c490-441d-b3b0-defb5bae2529",
  "b245039e-cc04-4a26-9b38-db69f43c06cc",
  "d5a59854-8d9f-4192-8699-49dd13673df8",
  "27b33755-e4ce-4d3d-ac91-8f74950d41fc",
  "117cc26c-a993-4be6-9a5d-6a8964723bce"
}
function isVip()
  return activity.getSharedData("VIP")
end
function isBaipiaoVip()
  return activity.getSharedData("VIP") and not(table.find(vipUuids,activity.getSharedData("VIPUUID")))
end
function isSVip()
  return activity.getSharedData("VIP") and table.find(vipUuids,activity.getSharedData("VIPUUID"))
end
function isBadVip()
  return activity.getSharedData("BadVIP") and activity.getSharedData("VIP")
end
function isBlackVip()
  return activity.getSharedData("BlackVip") and activity.getSharedData("BadVIP") and activity.getSharedData("VIP")
end
function isWhiteVip()
  return activity.getSharedData("WhiteVip") and activity.getSharedData("VIP")
end
function delVip()
  activity.setSharedData("VIP",false)
  activity.setSharedData("BadVIP",false)
  activity.setSharedData("WhiteVip",false)
  activity.setSharedData("BlackVip",false)
  activity.setSharedData("CancelledVIP",true)
end
function setVip(Uuid)
  if activity.getSharedData("CancelledVIP") then
    return false,"系统错误"
  end
  if isSVip() then
    return false,"您已经激活，无需再次激活"
  end

  if isWhiteVip() then
    if table.find(vipUuids,Uuid) then
      activity.setSharedData("VIPUUID",Uuid)
      return true,"虽然你激活不了哈兔Box，但是哈兔Box可以用你的激活码激活自己啊"
    end
   elseif isBlackVip() then
    if table.find(vipUuids,Uuid) then
      activity.setSharedData("BlackVip",false)
      activity.setSharedData("WhiteVip",true)
      return false,"没有激活成功，但是您已经解除3s选择工具的限制了"
     else
      return false,("你就没个正版激活码？给你一个吧，接着：%s(别忘了本软件已黑化)"):format(vipUuids[math.random(1,#vipUuids)])
    end
   elseif isBadVip() then
    --activity.setSharedData("willBlackVip",true)
    task(2000,function()
      activity.setSharedData("BlackVip",true)
      --activity.setSharedData("willBlackVip",false)
      os.exit()
    end)
    return false,"对不起，因您没有权利激活，本软件将在2s内黑化。"
  end
  if table.find(vipUuids,Uuid) then
    activity.setSharedData("VIP",true)
    activity.setSharedData("VIPUUID",Uuid)
    return true,"恭喜你已经成为VIP用户(别以为我不知道你激活码哪里来的)"
   elseif table.find(fuckUuids,Uuid) then
    activity.setSharedData("willBadVIP",true)
    task(1000,function()
      activity.setSharedData("VIP",true)
      activity.setSharedData("BadVIP",true)
      activity.setSharedData("willBadVIP",false)
      MyToast("状态已保存")
    end)
    return false,"高尚的VIP他不香吗？既然你想怎么来，那么恭喜您已获得终生不能成为高尚的正版VIP的用户。如果您在1s内不强制停止此应用，那么此应用会禁止您激活VIP。"
   else
    return false,"VIP激活码错误"
  end
end